package assists.resource
{
	import assists.URI;

	public class ResourceManager
	{
		private var _resourceList:Vector.<ResourceLoaderData>;
		
		public function ResourceManager():void
		{
		}
		
		
		public function addResource(resourceLoaderData:ResourceLoaderData):void
		{
			if(resourceLoaderData == null) return;
			
			if(this._resourceList == null) this._resourceList = new Vector.<ResourceLoaderData>();
			
			var varData:ResourceLoaderData = this.getResource(resourceLoaderData.key);
			
			if(varData == null){
				this._resourceList.push(resourceLoaderData);
			}
		}
		
		public function getResource(key:String):ResourceLoaderData
		{	
			if(this._resourceList == null || this._resourceList.length == 0) return null;
			
			for each(var resourceLoaderData:ResourceLoaderData in this._resourceList){
				if(resourceLoaderData.key == key) return resourceLoaderData;
			}
			
			return null;
		}
		
		public function clear():void
		{
			if(this._resourceList == null) return;
			
			var len:int = this._resourceList.length;
			
			for(var index:int = 0; index < len; index ++){
				
				delete this._resourceList[index];
			}
			
			this._resourceList.splice(0, len);
		}
	}
}